const INFO_KEY = "smart_mall";
const SEARCH_KEY = "history_list";

//獲取歷史記錄
export const getHistoryList = () => {
  const result = localStorage.getItem(SEARCH_KEY);
  return result ? JSON.parse(result) : [];
};

//設置歷史記錄
export const setHistoryList = (Array) => {
  localStorage.setItem(SEARCH_KEY, JSON.stringify(Array));
};

//設置個人信息
export const setInfo = (obj) => {
  localStorage.setItem(INFO_KEY, JSON.stringify(obj));
};

//獲取個人信息
export const getInfo = () => {
  const res = localStorage.getItem(INFO_KEY);
  return res ? JSON.parse(res) : { token: "", userId: "" };
};

//移除個人信息
export const removeInfo = () => {
  localStorage.removeItem(INFO_KEY);
};
